from importlib import import_module
from settings import HARDWARE_CLASS_DICT


def get_host_msg(my_ssh, host):  # 获取主机中的各硬件信息
    host_msg = {}
    for key, path in HARDWARE_CLASS_DICT.items():
        module_path, cls_name = path.rsplit('.', maxsplit=1)
        module = import_module(module_path)
        cls = getattr(module, cls_name)
        obj = cls()
        msg = obj.collect(my_ssh, host)

        host_msg[key] = msg

    return host_msg
